﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace Space_Cleaner.SpaceCleaner
{
    class SC_Script
    {
        private ContentManager contentMgr;
        private SC_World world;
        private LinkedList<SC_AbstractScriptEvent> events;

        public SC_Script(SC_World _world, ContentManager _contentMgr)
        {
            this.world = _world;
            this.contentMgr = _contentMgr;
            this.events = new LinkedList<SC_AbstractScriptEvent>();
        }

        public void addEvent(SC_AbstractScriptEvent _event)
        {
            this.events.AddLast(_event);
        }

        public void update(GameTime gameTime)
        {
            LinkedList<SC_AbstractScriptEvent> toRemove = new LinkedList<SC_AbstractScriptEvent>();
            foreach (SC_AbstractScriptEvent _event in events)
                if (_event.update(gameTime, world, contentMgr))
                    toRemove.AddLast(_event);

            foreach (SC_AbstractScriptEvent _event in toRemove)
                events.Remove(_event);
        }
    }
}
